package com.seex.motor;

import android.util.Log;


/**
 * Created by henry  16/5/3.
 */
public class Motor2 {
    private static int mFb = -1;

    private static int open() {
        mFb = MotorController.openMotor();
        logMsg("-------motor---- open : " + mFb);
        MotorController.startMotor(mFb);
        logMsg("-------motor---- start : " + mFb);
        return mFb;
    }

    private static void close() {
        if (mFb > -1) {
            MotorController.stopMotor(mFb);
            logMsg("-------motor---- stop : " + mFb);
            MotorController.closeMotor(mFb);
            logMsg("-------motor---- close : " + mFb);
        }
        mFb = -1;
    }

    public static void startMotor() {
        stopMotor();
        open();
        if (mFb > -1) {
            MotorController.netStart(mFb);
            logMsg("-------motor----- startMotor : " + mFb);
        }

    }

    public static void stopMotor() {
        if (mFb > -1) {
            MotorController.netStop(mFb);
            logMsg("-------motor----- stopMotor : " + mFb);
        }
        close();
    }

    static void logMsg(String msg){
        Log.d("Motor",msg);
    }
}
